package com.cy.milktea.pojo.System;



public class JsonResult {

    private Integer status;  //--->状态码 1:成功   0:失败
    private String msg;  //------->返回的信息
    private Object data;  //------>返回的数据


    private JsonResult(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }


    public static JsonResult ok(String msg, Object data) {
        return new JsonResult(1, msg, data);
    }

    public static JsonResult ok(String msg) {
        return ok(msg, null);
    }

    public static JsonResult ok(Object data) {
        return ok("ok!", data);
    }

    public static JsonResult ok() {
        return ok("ok!");
    }

    public static JsonResult error(String msg, Object data) {
        return new JsonResult(0, msg, data);
    }

    public static JsonResult error(String msg) {
        return error(msg, null);
    }

    public static JsonResult error(Object data) {
        return error("error!", data);
    }

    public static JsonResult error() {
        return error("error!");
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "JsonResult{" +
                "status=" + status +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
